<template>
	<view :class="['dhcc-base', themeName]"
		style="padding-top: 176rpx;display: flex;flex-direction: column;align-items: center;">
		<image style="width: 150rpx;height: 150rpx;border-radius: 75px;overflow: hidden;margin-bottom: 22rpx;"
			src="/static/images/icon/denglu.png" />
		<view style="font-weight: bold;margin-bottom: 160rpx;">
			<text>江西省保健信息管理系统</text>
		</view>
		<view style="font-size: 37rpx;font-weight: bold;margin-bottom: 84rpx;">
			<text>授权绑定手机号 为您提供更好的服务</text>
		</view>
		<view style="width: 590rpx;height: 85rpx;">
			<button style="background-color: #067FFA;" type="primary" open-type="getPhoneNumber"
				@getphonenumber="getPhoneNumber">一键登录</button>
				<view class="dhcc-entry-page-version">版本号：v1.0</view>
		</view>
		<!-- <view class="dhcc-entry-page-copyright">
		  <image class="dhcc-entry-page-copyright-img" src="/static/images/page/logo2.png" mode="widthFix" />
		  <text class="dhcc-entry-page-copyright-text">©东华医为科技有限公司版权所有</text>
		</view> -->
	</view>
</template>

<script>
	import tokenCache from '@/request/token/tokenCache'
	import commonRequest from '@/request/commonRequest'
	import showModal from '@/utils/showModalHandler'
	export default {
		data() {
		  return {
		    
		  }
		},
		methods: {
			getPhoneNumber(e) {
				if (e.detail.errMsg == 'getPhoneNumber:ok') {
					/* tokenCache.set(true, "朱彬")
					uni.switchTab({
						url: '/pages/loginPage/home-page'
					}); */ 
					uni.login({
					  success (res) {
					    if (res.code) {
					      //发起网络请求
					      const obj = {
					      	'phoneCode': e.detail.code,
							'openIdCode': res.code
					      }
						  uni.showLoading({
						  	title: '正在登录！',
							mask: true
						  })
					      commonRequest.loginRequest(obj).then(result => {
							  uni.hideLoading()
							if(result.data.opFlg == 1){
								tokenCache.set(true, result.data.user)
								uni.switchTab({
									url: '/pages/loginPage/home-page'
								});
							}else{
								showModal.showToast("登录失败，请联系管理员！")
							}
					      })
					    } else {
					      console.log('登录失败！' + res.errMsg)
					    }
					  }
					})
				}
			}
		}
	}
</script>

<style>
	.dhcc-base {
	  padding-bottom: var(--padding-small);
	}
	.dhcc-entry-page-version {
	  font-size: var(--font-size-text-small);
	  color: var(--dhcc-sub-color);
	  text-align: center;
	  margin-top: var(--padding-medium);
	}
	.dhcc-entry-page-copyright {
	  position: absolute;
	  left: 0;
	  bottom: 60rpx;
	  width: 100%;
	  text-align: center;
	}
	.dhcc-entry-page-copyright-img {
	  width: 220rpx;
	  vertical-align: middle;
	}
	.dhcc-entry-page-copyright-text {
	  color: var(--dhcc-sub-color);
	  font-size: var(--font-size-text-minimum);
	  vertical-align: middle;
	  margin: 0 -10rpx 10rpx 0;
	}
</style>